import 'package:flutter/material.dart';


class PageViewDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return PageView(
      // scrollPage效果
      // pageSnapping: false,
      // 反向
      // reverse: true,
      // 上下滚动 还是左右滚动
      scrollDirection: Axis.horizontal,
      controller: PageController(
        initialPage: 1,
        keepPage: false,
        viewportFraction: 1.0
      ),
      onPageChanged: (currentPage)=>debugPrint('Page:$currentPage'),
      children: <Widget>[
        Container(
          color: Colors.brown[500],
          alignment: Alignment(0,0),
          child: Text(
            'One',
            style: TextStyle(
              fontSize: 32,
              fontWeight: FontWeight.bold
            ),
          ),
        ),
        Container(
          color: Colors.red[500],
          alignment: Alignment(0,0),
          child: Text(
            'Two',
            style: TextStyle(
              fontSize: 32,
              fontWeight: FontWeight.bold
            ),
          ),
        ),
        Container(
          color: Colors.green[500],
          alignment: Alignment(0,0),
          child: Text(
            'Three',
            style: TextStyle(
              fontSize: 32,
              fontWeight: FontWeight.bold
            ),
          ),
        )
      ],
    );
  }
}